import type {
  DepartData,
  OrderListData,
  OrderParams,
  OrderPreData,
  OrderPreParams,
  OrderQuery,
  PayParams,
  UploadImage
} from '@/types/consult'
import type { PatientItem } from '@/types/patient'
import request from '@/utils/request'

//获取科室的数据
export const getDepListAPI = () => {
  return request.get<null, DepartData[]>('/dep/all')
}

//上传图片
export const upLoadImageAPI = (filePath: string) => {
  return request.upload<null, UploadImage>('/upload', {
    filePath,
    name: 'file',
  })
}

//获取预支付信息
export const getConsultOrderPreAPI = (params: OrderPreParams) => {
  return request.get<null, OrderPreData>('/patient/consult/order/pre', {
    params,
  })
}

//获取患者信息
export const getPatientInfoAPI = (id: string) => {
  return request.get<null, PatientItem>(`/patient/info/${id}`)
}

//生成订单
export const createConsultOrderAPI = (data: OrderParams) => {
  return request.post<null, { id: string }>('/patient/consult/order', data)
}

//获取支付地址
export const getConsultOrderPayUrlAPI = (data: PayParams) => {
  return request.post<null, { payUrl: string }>('/patient/consult/pay', data)
}

//获取问诊订单列表
/**
 * 医生问诊列表
 */
export const getOrderListApi = (data:OrderQuery) => {
  return request.get<null, OrderListData>('/patient/consult/order/list', { params: data })
}